package com.sas.domain;

import javax.persistence.Entity;

import org.springframework.util.Assert;

@Entity
public class Telephone extends PersistentEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -37882512063586051L;
	private Integer countryCode;
	private Integer areaCode;
	private Integer telephoneNumber;
	private String intern;
	
	private boolean fax;
	
	Telephone() {
	}

	public Telephone(Integer countryCode, Integer areaCode,
			Integer telephoneNumber, String intern) {
		setCountryCode(countryCode);
		setAreaCode(areaCode);
		setTelephoneNumber(telephoneNumber);
		setIntern(intern);
	}

	public Integer getCountryCode() {
		return countryCode;
	}

	public void setCountryCode(Integer countryCode) {
//		Assert.notNull(countryCode);
		this.countryCode = countryCode;
	}

	public Integer getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(Integer areaCode) {
//		Assert.notNull(areaCode);
		this.areaCode = areaCode;
	}

	public Integer getTelephoneNumber() {
		return telephoneNumber;
	}

	public void setTelephoneNumber(Integer telephoneNumber) {
		Assert.notNull(telephoneNumber);
		this.telephoneNumber = telephoneNumber;
	}

	public boolean isFax() {
		return fax;
	}

	public void setFax(boolean fax) {
		this.fax = fax;
	}

	public void setIntern(String intern) {
//		Assert.hasText(intern);
		this.intern = intern;
	}

	public String getIntern() {
		return intern;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((areaCode == null) ? 0 : areaCode.hashCode());
		result = prime * result
				+ ((countryCode == null) ? 0 : countryCode.hashCode());
		result = prime * result + (fax ? 1231 : 1237);
		result = prime * result + ((intern == null) ? 0 : intern.hashCode());
		result = prime * result
				+ ((telephoneNumber == null) ? 0 : telephoneNumber.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Telephone other = (Telephone) obj;
		if (areaCode == null) {
			if (other.areaCode != null)
				return false;
		} else if (!areaCode.equals(other.areaCode))
			return false;
		if (countryCode == null) {
			if (other.countryCode != null)
				return false;
		} else if (!countryCode.equals(other.countryCode))
			return false;
		if (fax != other.fax)
			return false;
		if (intern == null) {
			if (other.intern != null)
				return false;
		} else if (!intern.equals(other.intern))
			return false;
		if (telephoneNumber == null) {
			if (other.telephoneNumber != null)
				return false;
		} else if (!telephoneNumber.equals(other.telephoneNumber))
			return false;
		return true;
	}
	
	

}
